<% title taxonomy_upcase %>
<% title_actions new_link(taxonomy_new),
                 display_link_if_authorized(_("Mismatches Report"), hash_for_mismatches_taxonomies_path, :class => 'btn btn-default'),
                 help_button %>

<% if @count_nil_hosts > 0 %>
  <%= alert :class => 'alert-warning', :header => '',
            :text => (n_('There is', 'There are', @count_nil_hosts) + ' ' +
                      link_to(n_("%{count} host with no %{taxonomy_single} assigned",
                      "%{count} hosts with no %{taxonomy_single} assigned", @count_nil_hosts) %
                      {:count => @count_nil_hosts , :taxonomy_single => taxonomy_single },
                      hosts_path(:search => "not has #{controller_name.singularize}"))).html_safe %>
<% end %>
<table class="<%= table_css_classes 'table-fixed' %>">
  <thead>
    <tr>
      <th><%= sort :title, :as => s_("Taxonomy|Name") %></th>
      <th><%= _("Hosts") %></th>
      <th><%= _('Actions') %></th>
    </tr>
  </thead>
  <tbody>
    <% @taxonomies.each do |taxonomy| %>
      <tr class="<%= cycle("even", "odd") %>">
        <td><%= label_with_link(taxonomy, 150) %></td>
        <td><%= link_to hosts_count[taxonomy], hosts_path(:search => "#{controller_name.singularize} = \"#{taxonomy}\"") %></td>
        <td>
          <%= action_buttons(
            display_link_if_authorized(_("Edit"), hash_for_edit_taxonomy_path(taxonomy).merge(:auth_object => taxonomy) ),
            display_link_if_authorized(_("Nest"), hash_for_nest_taxonomy_path(taxonomy).merge(:auth_object => taxonomy) ),
            display_link_if_authorized(_("Clone"), hash_for_clone_taxonomy_path(taxonomy).merge(:auth_object => taxonomy) ),
            display_delete_if_authorized(hash_for_taxonomy_path(taxonomy).merge(:auth_object => taxonomy), :data => { :confirm => taxonomy.hosts.count.zero? ? _("Delete %s?") % taxonomy.name : n_("%{taxonomy_type} %{taxonomy_name} has %{count} host that will need to be reassociated after deletion. Delete %{taxonomy_name2}?", "%{taxonomy_type} %{taxonomy_name} has %{count} hosts that will need to be reassociated after deletion. Delete %{taxonomy_name2}?", taxonomy.hosts.count) % {:taxonomy_type => taxonomy_title, :taxonomy_name => taxonomy.name, :count => taxonomy.hosts.count, :taxonomy_name2 => taxonomy.name}}, :action => :destroy),
            (link_to((_("Select hosts to assign to %s") % taxonomy.name), assign_hosts_taxonomy_path(taxonomy)) if @count_nil_hosts > 0),
            (link_to(n_("Assign the %{count} host with no %{taxonomy_single} to %{taxonomy_name}", "Assign all %{count} hosts with no %{taxonomy_single} to %{taxonomy_name}", @count_nil_hosts) % {:count => @count_nil_hosts, :taxonomy_single => taxonomy_single, :taxonomy_name => taxonomy.name}  ,
                assign_all_hosts_taxonomy_path(taxonomy),
                :method => :post) if @count_nil_hosts > 0)
            )%>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<%= will_paginate_with_info @taxonomies %>
